<?php
	include('connect_db.php');
	/*if logged in, redirect to homepage */
	if (!checkLoggedin())
	{
		header('Location: login.php');
	}

	if(ISSET($_GET) && ISSET($_GET['bill_id']) && ISSET($_GET['user_id']) )
	{
	    $query = "SELECT * FROM bills
					   WHERE user_id = ".$_GET['user_id'];
		$bill = mysql_fetch_array(mysql_query($query));

		if(!ISSET($bill['amount']))
		{//the user is not the creator of the bill
			header('Location: index.php');
		}
		
	    $query = "UPDATE bills_users
					SET if_paid = True
					WHERE user_id = ".$_GET['user_id'].
					" AND bill_id = ".$_GET['bill_id'];
	
		mysql_query($query);
	}
	header('Location: mybills.php');//a user not belong to this house
?>